package com.zhuj.core.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtil {

    //是否为空字符串
    public static boolean isEmpty(String string){
        if (string == null||string.length()==0)
            return true;
        return false;
    }

    //驼峰转下划线
    public static String humpToLine(String fieldName){
        Pattern humpPattern = Pattern.compile("[A-Z]");
        Matcher matcher = humpPattern.matcher(fieldName);
        StringBuffer sb = new StringBuffer();
        while(matcher.find()){
            matcher.appendReplacement(sb, "_"+matcher.group(0).toLowerCase());
        }
        matcher.appendTail(sb);
        return sb.toString();
    }

    public static String lastSubCharStr(String string,String ch){
        return string.substring(string.lastIndexOf(ch)+1);
    }

    public static void main(String[] args) {
        System.out.println(lastSubCharStr("class com.zhuj.server.NrpcServer","."));
    }

}
